<template>
    <div>
        <h1>病房显示页面</h1>
        科室:               <select v-model="page.id" >
                                <option value="0">请选择</option>
                                <option v-for="a in Xiala1" :value="a.kid">{{a.keName}}</option>
                            </select>
                            &nbsp;&nbsp;&nbsp;
        病房名称: <input type="text" v-model="page.name">
        &nbsp;&nbsp;&nbsp;

        <input type="button" value="查询" @click="Show" class="btn btn-success">
        &nbsp;&nbsp;&nbsp;
        <a href="/BingHomeAdd">新增病房</a> &nbsp;&nbsp;&nbsp;
        <a href="/Show">返回首页</a> &nbsp;&nbsp;&nbsp;
     
        <table class="table">
                    <thead>
                        <tr>
                            <td>ID</td>
                            <td>病房号</td>
                            <td>病房名称</td>
                            <td>所属科室</td>
                            <td>床位总数量</td>
                            <td>空闲床数量</td>
                            <td>状态</td>
                            <td>创建日期</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="a in data">
                            <td>{{a.bid}}</td>
                            <td>{{a.bnumber}}</td>
                            <td>{{a.bName}}</td>
                            <td>{{a.keName}}</td>
                            <td>{{a.bednum}}</td>
                            <td>{{a.bedKong}}</td>
                            <td>{{a.zhuName}}</td>
                            <td>{{a.times.substring(0,10)}}</td>
                            <td>
                                <span>
                                        <input v-if="a.zhuName=='未满'" type="button" value="启用" @click="UpdateKe(a.bid)" class="btn - btn-success">
                                        <input v-if="a.zhuName=='维修'" type="button" value="启用" @click="UpdateKe(a.bid)" class="btn - btn-success">
                                        <input v-if="a.zhuName=='启用'" type="button" value="维修" @click="UpdateKe(a.bid)" class="btn - btn-success">
                                </span>
                                
                            </td>
                        </tr>
                    </tbody>
            </table>
    </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'
const router = useRouter();

onMounted(()=>{
    Show()
    Xiala()
})

const Xiala1=ref([{
    "kid": 4,
    "keName": "一类科室",
    "kePeople": "15",
    "keMiaoS": "心血疾病专家",
    "keTimes": "2025-05-19T00:00:00",
    "keLuoji": true
}])

const Xiala=()=>{
    axios.get("/api/KeHome/GetKeshiQuan").then(res=>{
        Xiala1.value=res.data;
    })
}




const data = ref([
    {
        "bid": 3,
    "bnumber": "101",
    "bName": "",
    "kid": 4,
    "bednum": 20,
    "zid": 3,
    "bedKong": 15,
    "times": "2025-05-19T12:00:52.4490514",
    "zhuName": "未满",
    "keName": ""
    }
])
const page = ref({
            id:0,
            name:''
});

const Show=()=>{
    axios.get("/api/BingHome/ShowBingHome",{params:page.value}).then(res=>{
           data.value=res.data;
           
    })
}



const UpdateKe=(mid:any)=>{
    if(!confirm("确认修改吗?"))
{
return;
}
    axios.get("/api/BingHome/ZhuangUpdate",{params:{id:mid}}).then(res=>{
           if(res.data>0)
           {
                alert("状态修改成功!");
                Show()
           }
           else{
             alert("状态修改失败!");
             return;
           }
           
    })
}


</script>

<style scoped>

</style>